<?php


declare(strict_types=1);

/**
 * 小程序活动页
 * User：Abell
 * Date：2020/4/21
 */

namespace App\Controller\Admin;

use App\Controller\AbstractController;
use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\Di\Annotation\Inject;
use App\Service\WxnoticeService;

class WxnoticeController extends AbstractController
{
    /**
     * @Inject
     * @var WxnoticeService
     */
    protected $service;

    /** 小程序活动页列表查看和编辑
     * @Author abell
     * @DateTime 2020-05-27
     * @return object
     */
    public function index(){
        return $this->jsonApi($this->service->listNotice());
    }

    /** 基本的活动信息列表单条查看和编辑
     * @Author abell
     * @DateTime 2020-05-27
     * @return object
     */
    public function edit(RequestInterface $request){
        if($request->isMethod('get')){
            $data = $this->service->getNotice($request->all());
        }else{
            $data = $this->service->editNotice($request->all());
        }
        return $this->jsonApi($data);
    }
}